package com.hdyg.sixg.activity.application;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hdyg.sixg.R;
import com.hdyg.sixg.activity.WebActivity;
import com.hdyg.sixg.activity.common.BaseActivity;
import com.hdyg.sixg.entry.ShareBean;
import com.hdyg.sixg.mvp.Contrant.CApplyMerchant;
import com.hdyg.sixg.mvp.base.BasePresenter;
import com.hdyg.sixg.mvp.base.BaseUrl;
import com.hdyg.sixg.mvp.base.GetParamUtil;
import com.hdyg.sixg.mvp.base.SpMsg;
import com.hdyg.sixg.mvp.presenter.PApplyMerchant;
import com.hdyg.sixg.util.StringUtil;

import butterknife.BindView;


/**
 * @author CZB
 * @describe 申请商家
 * @time 2019/4/9 15:42
 */
public class ApplyMerchantActivity extends BaseActivity implements CApplyMerchant.IVApplyMerchant {

    @BindView(R.id.ll_top_left)
    LinearLayout llTopLeft;
    @BindView(R.id.tvTopTitle)
    TextView tvTopTitle;
    @BindView(R.id.bt_sure)
    Button btSure;

    private CApplyMerchant.IPApplyMerchant mPresenter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_apply_merchant;
    }

    @Override
    protected void initView() {
        onClickListener();
        tvTopTitle.setText(R.string.application_9);
    }

    private void onClickListener() {

        llTopLeft.setOnClickListener(v -> finish());

        //立即申请
        btSure.setOnClickListener(v -> {
            if (StringUtil.isFastDoubleClick()) {
                return;
            }
            mPresenter.pGetApply(BaseUrl.APPLY_MERCHANT_URL, GetParamUtil.getApplyMerchantParam());
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void createPresenter() {
        mPresenter = new PApplyMerchant(this);
    }

    @Override
    public void vGetApplySuccess(ShareBean dataBean) {
        if (!TextUtils.isEmpty(dataBean.getUrl())) {
            mBundle = new Bundle();
            mBundle.putString(SpMsg.URL, dataBean.getUrl());
            startActivity(WebActivity.class, mBundle);
            finish();
        }
    }
}
